package com.lxp.base.log;


import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;

/**
 * Created by lxp on 2017/6/5.
 * 日志输出
 */

public class Log {
    public static boolean ISDEBUG = false;

    static {
        Logger.addLogAdapter(new AndroidLogAdapter());
    }

    public static void setDebug(boolean isDebug) {
        ISDEBUG = isDebug;
    }


    public static boolean isDebug() {
        return ISDEBUG;
    }

    public static void d(String content) {
        if (!isDebug()) return;
        Logger.d(content);

    }

    public static void d(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.d(content, tr);
    }

    public static void e(String msg) {
        if (!isDebug()) return;
        Logger.e(msg);
    }

    public static void e(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.e(content, tr);
    }

    public static void e(Throwable throwable, String message, Object... args) {
        if (!isDebug()) return;
        Logger.e(throwable, message, args);
    }

    public static void i(String content) {
        if (!isDebug()) return;
        Logger.i(content);
    }

    public static void i(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.i(content, tr);
    }

    public static void v(String content) {
        if (!isDebug()) return;
        Logger.v(content);
    }

    public static void v(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.v(content, tr);
    }

    public static void w(String content) {
        if (!isDebug()) return;
        Logger.w(content);
    }

    public static void w(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.w(content, tr);
    }


    public static void wtf(String content) {
        if (!isDebug()) return;
        Logger.wtf(content);
    }

    public static void wtf(String content, Throwable tr) {
        if (!isDebug()) return;
        Logger.wtf(content, tr);
    }


    /**
     * Formats the json content and print it
     *
     * @param json the json content
     */
    public static void json(String json) {
        if (!isDebug()) return;
        Logger.json(json);
    }

    /**
     * Formats the json content and print it
     *
     * @param xml the xml content
     */
    public static void xml(String xml) {
        if (!isDebug()) return;
        Logger.xml(xml);
    }


    public static void log(String tag, String msg) {
        if (!isDebug()) return;
        Logger.t(tag).d(msg);
    }
}
